﻿using System;
using System.Windows.Documents;

namespace TextPlus.Extensions
{
    public static class ExtensionsClass
    {
        internal static Run Clone(this Run run, TextBlockPlus parent)
        {
            var clone = new Run();
            clone.Text = run.Text;
            return clone;
        }

        internal static Link Clone(this Link link, TextBlockPlus parent)
        {
            var clone = new Link(parent);
            clone.Text = link.Text;
            clone.NavigateUri = link.NavigateUri;
            return clone;
        }

        internal static Inline Clone(this Inline inline, TextBlockPlus parent)
        {
            if (inline is Run)
                return ((Run) inline).Clone(parent);
            if (inline is Link)
                return ((Link) inline).Clone(parent);
            throw new NotSupportedException();
        }
    }
}
